SET SERVEROUTPUT ON SIZE 1000000;
SET VERIFY OFF

DECLARE
	l_total_extracted	NUMBER;
	l_total_imported	NUMBER;				
	l_func_id			VARCHAR2(100):='CAPPOREC_SUPPLIER_CONTACT';
	l_code VARCHAR2(100):=UPPER('&1');
BEGIN
	SELECT COUNT(1)
	INTO l_total_extracted        
	FROM   PO_VENDOR_CONTACTS PVC,
           	 PO_VENDOR_SITES_ALL PVS,
           	 HR_ORGANIZATION_INFORMATION HOI
    	WHERE  PVC.VENDOR_SITE_ID = PVS.VENDOR_SITE_ID       
    	AND    PVS.ORG_ID = HOI.ORGANIZATION_ID
    	AND    HOI.ORG_INFORMATION_CONTEXT = 'Operating Unit Information' 
    	AND    HOI.ORG_INFORMATION3 =  (select set_of_books_id
      								    from   gl_sets_of_books
      									where  upper(short_name) = upper(l_code));
	
	SELECT COUNT(1) 
	INTO l_total_imported
	FROM CRST_PO_VENDOR_CONTACTS;

	dbms_output.put_line('Function: '||l_func_id);		
	dbms_output.put_line('Total Extracted: '||TO_CHAR(l_total_extracted)) ;
	dbms_output.put_line('Total Imported:  '||TO_CHAR(l_total_imported));
	IF l_total_extracted <> l_total_imported THEN
		dbms_output.put_line('Error: No. of Records do not match!');
	END IF;		
						
EXCEPTION
	WHEN OTHERS THEN	
		dbms_output.put_line('Function Error: '||l_func_id);			
END;
/
